AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')

function ENT:Use(ply, caller)
	if !self.dt.Sparking then
		if self.dt.Upgrade == 0 then
			if ply:Health() < ply:GetMaxHealth() then
				ply:SetHealth(ply:Health() + 15)
				self:EmitSound("HealthVial.Touch")
				if ply:Health() > ply:GetMaxHealth() then ply:SetHealth(ply:GetMaxHealth()) end
			end
		else
			if ply:Health() < ply:GetMaxHealth() then
				ply:SetHealth(ply:Health() + 20)
				self:EmitSound("HealthVial.Touch")
				if ply:Health() > ply:GetMaxHealth() then ply:SetHealth(ply:GetMaxHealth()) end
			end
			
			if ply:Armor() < 100 then
				ply:SetArmor(ply:Armor() + 15)
				self:EmitSound("HealthVial.Touch")
				if ply:Armor() > 100 then ply:SetArmor(100) end
			end
		end
		
		self.dt.Sparking = true
		timer.Create(tostring(self) .. "resupply", self.SupplyDelay, 1, self.SetSparking, self, false)
	end
end

function ENT:OnRemove()
	timer.Destroy(tostring(self.Entity) .. "resup")
end

